

<script type="text/javascript">
function editPhoto(obj, isShow){
	if(isShow){
		$('headerBox_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').hide();
		$('boxEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').show();
		if($('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>')) $('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').addClass('disableEdit');
	}else{
		$('headerBox_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').show();
		$('boxEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').hide();
		if($('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>')) $('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').removeClass('disableEdit');
	}
}
en4.core.runonce.add(function() {

	  var descEls = $$('.musics_viewmedia_info_caption');
	    if( descEls.length > 0 ) {
	      descEls[0].enableLinks();
	    }
   
			
	  
	 if($('frmEditPhoto_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>')) $('frmEditPhoto_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').addEvent('submit', function(e){
			e.stop();
			var form_values  = $('frmEditPhoto_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').toQueryString();
	        	form_values += '&format=json';
				console.log(form_values);
	        en4.core.request.send(new Request.JSON({
        	    url : en4.core.baseUrl + 'fmusic/music/quick-edit',
        	    data : form_values
        	}), {
        	   	'element' : $('informations_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>')
        });	
	 });
	 
	 $('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').removeClass('disableEdit');
	 $('titlePhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').addEvents({
		'focus': function(){
			if (this.value.contains('<?php echo $this->translate('Write a title...')?>')) this.value = '';
		},
		'blur': function(){
			if (this.value == '') this.value = '<?php echo $this->translate('Write a title...')?>';
		}
	 });
	 $('desPhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').addEvents({
			'focus': function(){
				if (this.value.contains('<?php echo $this->translate('Write a description...')?>')) this.value = '';
			},
			'blur': function(){
				if (this.value == '') this.value = '<?php echo $this->translate('Write a description...')?>';
			}
		 });
});
    var tagAction = window.tagAction = function(tag){
      $('tag').value = tag;
      $('filter_form').submit();
    }
</script>
<div class="informations" id="informations_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>">
			<div id="headerBox_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" style="display: block;">
				<div class="boxInfoUser">
					<div class="boxiconUser">
				        <?php echo $this->htmlLink($this->music->getOwner()->getHref(),$this->itemPhoto($this->music->getOwner(), 'thumb.icon')); ?>
					</div>
					<div class="boxInfoPhoto">
						<div class="boxUserLink"><?php echo $this->music->getOwner()->__toString()?></div>
						<div class="boxTimestamp"><?php echo $this->timestamp($this->music->modified_date)?></div>
					</div>
				</div>
				
				<div style="clear: both;"></div>
				<br>
				<?php if($this->music->getTitle()):?>
					<div class="musics_viewmedia_info_title"><?php echo $this->music->getTitle()?></div>
				<?php endif;?>
			    <?php $isWith = false; if( $this->music->getDescription() ): $isWith = true;?>		       
			       <span>
			        <?php echo nl2br($this->music->getDescription()) ?>
			       </span>
			    <?php else: $isWith = false;?>
			     <?php if( $this->canEdit ): ?>
				    <div>				    	
				    	<a href="javascript: void(0);" onclick="editPhoto(this, true);$('desPhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').focus();"><?php echo $this->translate('Add a description');?></a>
				    </div>
				    
			    <?php endif;?>
			    <?php endif; ?>
				<span class="musics_viewmedia_info_tags" id="media_tags" style="display: none;">
	      			<?php echo ($isWith)?'&nbsp;&ndash;&nbsp;'. $this->translate('with ') : $this->translate('With ');?>
	    		</span>
				
				<?php if (count($this->musicTags )):?>
				<p><b><?php echo $this->translate('Tags');?>: </b>
					  <?php foreach ($this->musicTags as $tag): ?>
						<a href='javascript:void(0);' onclick='javascript:tagAction(<?php echo $tag->getTag()->tag_id; ?>);'>#<?php echo $tag->getTag()->text?></a>&nbsp;
					  <?php endforeach; ?>
				</p>	  
				<?php endif; ?>
	    	</div>
	    	<?php if($this->can_edit):?>
	    	<form id="frmEditPhoto_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" name="frmEditPhoto" method="post" enctype="application/x-www-form-urlencoded">
		    	<div id="boxEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" class="boxEdit" style="display: none;">
		    		<div class="musicTitle gen">
		    			<input class="titlePhotoValue" id="titlePhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" class="textInput" type="text" name="title" value="<?php echo ($this->music->getTitle())? $this->music->getTitle() : $this->translate('Write a title...');?>">
		    		</div>
		    		<div class="musicDes gen">
		    			<textarea id="desPhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" name="description" id="musicDesArea_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" class="areaDes"><?php echo ($this->music->getDescription()) ? strip_tags($this->music->getDescription()) : $this->translate('Write a description...')?></textarea>
		    		</div>
		    		<input type="hidden" value="<?php echo $this->music->getIdentity()?>" name="playlist_id">
					<div class="editActions">
						<button type="submit" name="submit" ><?php echo $this->translate('Save changes');?></button>
						<button type="button" name="cancel" onclick="editPhoto(this, false);"><?php echo $this->translate('Cancel');?></button>
					</div>		    	
		    	</div>
		    </form>
	    	<?php endif;?>
	    </div>
<form id='filter_form' class='global_form_box' method='post' action='<?php echo $this->url(array('module' => 'music', 'controller' => 'index', 'action' => 'browse'), 'default', true) ?>' style='display:none;'>
  <input type="hidden" id="tag" name="tag" value=""/>
</form>